package com.xiaomengkuan.user.config;

import com.xiaomengkuan.user.interceptor.SignatureInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Faraj Mujey
 * -- Creation Time: 2021-01-25 5:05 下午, File Encoding: utf8 --
 */
@Configuration
public class InterceptorConfigurer implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new SignatureInterceptor())
                .addPathPatterns("/**") // 拦截所有请求
                // TODO: 测试时暂时全放行 < 2021-02-10, farajmujey > 📣
                //.excludePathPatterns("/user/login/**") // 放行登陆请求
                .excludePathPatterns("/user/**")
                .excludePathPatterns("common/**")
                .excludePathPatterns("/swagger-resources/**", "/webjars/**",
                        "/v2/**", "/swagger-ui.html/**"); // 放行swagger2
    }
}
